package com.rabbitmq.delay.controller;

import com.rabbitmq.delay.producer.DelayMessageProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @author zhangwu
 * @create2021/6/16
 */
@RestController
@Slf4j
public class RabbitMQController {
    @Resource
    DelayMessageProducer delayMessageProducer;

    @RequestMapping("/rabbitmq")
    public void send(String message,int delay){
        log.info("当前时间:[{}],消息:[{}],延迟类型:[{}]", LocalDateTime.now(),message,delay);
        delayMessageProducer.send(message, Objects.requireNonNull(delay));
    }
}
